﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class admin_AdminStudentAudit : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            bindDateTable();
        }
    }

    private void bindDateTable()
    {
        DataTable dt = User_Control.getNotAccessStudentInfo();
        gv.DataSource = dt;
        gv.DataBind();
    }


    protected void gv_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        gv.PageIndex = e.NewPageIndex;
        bindDateTable();
    }
    protected void gv_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName.CompareTo("Accept") == 0)
        {
            int index = ((GridViewRow)((LinkButton)(e.CommandSource)).Parent.Parent).RowIndex;
            string studIdcard = gv.DataKeys[index].Values[0].ToString().Trim();
            
            if (User_Control.updateStudentStateByIdcard("0", studIdcard))
            {
                Response.Redirect(BSUtility.mainUrl + "admin/AdminStudentAudit.aspx");
            }
            
        }
        else if (e.CommandName.CompareTo("Deny") == 0)
        {
            int index = ((GridViewRow)((LinkButton)(e.CommandSource)).Parent.Parent).RowIndex;
            string studIdcard = gv.DataKeys[index].Values[0].ToString().Trim();          
            if (User_Control.deleteStudentInfoByIdcard(studIdcard))
            {
                Response.Redirect(BSUtility.mainUrl + "admin/AdminStudentAudit.aspx");
            }
        }
    }
}